package com.banana.manager.forest.controller.handle;

import com.banana.manager.forest.dao.handle.IAreaDao;
import com.banana.manager.forest.entity.handle.AreaBean;
import com.banana.manager.forest.service.impl.handle.AreaServiceImpl;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/area")
public class AreaController {

    @Resource
    private AreaServiceImpl areaService;

    @Resource
    private IAreaDao areaDao;

    @PostMapping("/addArea")
    public AreaBean addArea(@RequestBody AreaBean areaBean){
        return areaService.addNewArea(areaBean);
    }

    @GetMapping("/displayArea")
    public PageInfo<AreaBean> displayAllArea(Integer page, String areaName, String areaWoods, String className){
        return areaService.findBlurByPage(page, areaName, areaWoods, className);
    }

    @GetMapping("/noClassArea")
    public List<AreaBean> showNoClassArea(){
        return areaService.findNoClassArea();
    }

    @GetMapping("/allArea")
    public List<AreaBean> showAllArea(){
        return areaDao.getAreaWithClass();
    }

    @GetMapping("/getClassByArea")
    public AreaBean getArea(String areaName){
        return areaService.findClassByAreaName(areaName);
    }

}
